﻿/*<summary>
Created By : Swati
Created On : 10/16/2008
Class Name : Procedure_DataLoader
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/

using System.Xml;
using System.Data;
using System;
using Utils;
using System.Data.SqlClient;
using System.Collections;

namespace RegistrationController
{
    public class Procedure_DataLoader
    {
        public Hashtable Get_Procedure_Data()
        {
            Hashtable ht_procedureInfo = new Hashtable();
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataChecker dtc = new DataChecker();
            DataSet ds = new DataSet();

            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetProcedure", "TR");
                for (int indx = 0; indx < ds.Tables[0].Rows.Count; ++indx)
                {
                    DataRow dr = ds.Tables[0].Rows[indx];
                    String name = Convert.ToString(dr["Name"]);
                    String price = Convert.ToString(dr["Price"]);
                    ht_procedureInfo.Add(name, price);
                }

                return ht_procedureInfo;
            }
            catch (SqlException ex)
            {
                string errorMessage = String.Format(
                    "An Error Occurred While Loading the Consultant Information to the DB. Message: {0}", ex.Message);
                return ht_procedureInfo;
            }
            finally
            {
                DBL.Dispose();
                dtc.Dispose();
                ds.Dispose();
            }
        }

        public DataSet Get_Patient_Procedure_Data(string CRNumber)
        {
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataSet ds = null;

            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetPatientProcedureDetail", "TR",
                        new SqlParameter("@biCRN", CRNumber));
                
                return ds;
            }
            catch (SqlException ex)
            {
                string errorMessage = String.Format(
                    "An Error Occurred While Loading the Consultant Information to the DB. Message: {0}", ex.Message);
                return ds;
            }
            finally
            {
                DBL.Dispose();
                if (ds != null)
                {
                    ds.Dispose();
                }
            }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }
    }
}
